<?php
	include '../controllers/getAllToeflRecommands.php';
	
	date_default_timezone_set("PRC"); 
	$recommands = getAllRecommands();
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="../js/recommandmanager.js"></script>
</head>
<body>
	<a href="javascript:history.back(-1)">返回</a><hr/>
	<table border='2' rules='rows' cellpadding='8%' align='center' width='80%'>
		<tr><th colspan="2"><h2>添加托福机经推荐列表</h2></th></tr>
		<tr><th>日期说明</th><td><input id="title" type="text" size="100"></input></td></tr>
		<tr><th>是否发布</th><td><select id="status"><option value="0">不发布</option><option value="1">发布</option></select></td></tr>
		<tr align="center"><td colspan="2"><input type="button" value="添加托福机经列表" onclick="addRecommand();"></input></td> </tr>
	</table>
	<br />
	<br />
	<div id="recommand_list">
	<table border='2' rules='rows' cellpadding='8%' align='center' width='80%'>
		<tr><th colspan="6"><h2>托福机经推荐列表</h2></th></tr>
		<tr><th>推荐ID</th><th>日期说明</th><th>状态</th><th>更新时间</th><th colspan="2">操作</th></tr>
		<?php
		$recommandCount = count($recommands);
		for ($i = 0; $i < $recommandCount; $i++) {
			
			$recommand = $recommands[$i];
			$recommandId = $recommand->recommandId;
			$title = $recommand->title;
			$timestamp = $recommand->timestamp;
			$status = $recommand->status;
			$formatTime = date("y-m-d h:i:s",$timestamp);
			echo "<tr align='center'><td>$recommandId</td><td>$title</td>";
			if ($status == 0) {
				echo "<td>未发布</td>";
			}	
			else 
			{
				echo "<td>发布中</td>";
			}
			echo "<td>$formatTime</td>";
			echo "<td><input type='button' value='修改' onclick='gotoUpdateRecommand($recommandId,\"$title\",$status);'></input>";
			echo "<input type='button' value='删除' onclick='deleteRecommand($recommandId);'></input><td>";
			echo "</tr>";
		}
		?>
	</table>
	</div>
</body>
</html>